﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using System.Threading.Tasks;
using System.Reflection;

namespace SqlCommandHelper
{
    public static class PropertyAttributeValue
    {
        public static string GetDbFieldAttribute<TModel, TProperty>(Expression<Func<TModel, TProperty>> expression)
        {
            string propertyName = (expression.Body as MemberExpression).Member.Name;
            var attr = typeof(TModel).GetProperty(propertyName).GetCustomAttribute(typeof(DbField)) as DbField;
            return attr.CustomName;
        }
    }
}
